package itsource.cw.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

//这个配置类的作用：其实配置的就是swagger-ui主界面，右上角的那个下拉框
@Component
@Primary
public class DocumentationConfig implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
       List resources = new ArrayList<>();
       //配置访问的地址参数，由3部分组成： /hrm:网关的访问前缀；/system：访问具体资源服务的路由 ；/v2/api-docs ： 固定不变
       resources.add(swaggerResource("系统管理", "/hrm/system/v2/api-docs", "2.0"));
       return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}